import React, { Component } from 'react'
import { connect } from 'react-redux'
class List2 extends Component {
  changeData = () => {
    this.props.changeList([7,8,9])
  }
  render() {
    return (
      <div>
        list2
        <button onClick = { this.changeData }>
          改变
        </button>
        {
          this.props.list.map((item, index) => (
            <div key = { index }>{ item }</div>
          ))
        }
      </div>
    )
  }
}

export default connect(
  (state) => { return { list: state.list } },
  (dispatch) => {
    return {
      changeList (payload) {
        dispatch({
          type: 'CHANGE_LIST',
          payload
        })
      }
    }
  }
)(List2)